package br.com.usp.server;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import br.com.usp.shared.BMMDTO;



@Entity(name="TB_PROCESS_FLOW")
public class ProcessFlow {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="ID_FLOW")
    private int id;
	
	@Column(name="Nome")
	private String Descricao;
	
	@Column
    private String Tipo;
	
    @Column(name="Descricao")
    private String Representacao;
    
    @Column(name="ESQ")
	private int  left;
    
    @Column(name="CIMA")
	private int   top;

    @ManyToOne 
    @JoinColumn(name="ID_PROCESS", referencedColumnName="id_entidade") 
    private BMM processo;
    
    
    @OneToMany(cascade=CascadeType.ALL ,mappedBy="processo")
   	private List<ActivityFlow> listaActivity;
       

    @OneToMany(cascade=CascadeType.ALL ,mappedBy="de")
    private List<ConnectorProcess> listaConnectorProcessDe;
    
    @OneToMany(cascade=CascadeType.ALL ,mappedBy="para")
    private List<ConnectorProcess> listaConnectorProcessPara;
	
    @OneToMany(cascade=CascadeType.ALL ,mappedBy="processo")
  	private List<ConnectorActivity> connectorActivity;
  	
    
    public ProcessFlow()
    {
    	listaActivity = new ArrayList<ActivityFlow>();
    	connectorActivity = new ArrayList<ConnectorActivity>(); 
    	listaConnectorProcessPara = new ArrayList<ConnectorProcess>();
    	listaConnectorProcessDe = new ArrayList<ConnectorProcess>();
    }


    public ProcessFlow(BMMDTO bmm)
    {
    	this.id = bmm.getId();
    	this.Descricao = bmm.getDescricao();
    	this.Tipo = bmm.getTipo();
        this.Representacao = bmm.getRepresentacao();
        this.left = bmm.getLeft();
        this.top = bmm.getTop();
        listaActivity = new ArrayList<ActivityFlow>();
        connectorActivity = new ArrayList<ConnectorActivity>(); 
        listaConnectorProcessPara = new ArrayList<ConnectorProcess>();
    	listaConnectorProcessDe = new ArrayList<ConnectorProcess>();
    }
    
    
	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getDescricao() {
		return Descricao;
	}


	public void setDescricao(String descricao) {
		Descricao = descricao;
	}


	public String getTipo() {
		return Tipo;
	}


	public void setTipo(String tipo) {
		Tipo = tipo;
	}


	public String getRepresentacao() {
		return Representacao;
	}


	public void setRepresentacao(String representacao) {
		Representacao = representacao;
	}


	public int getLeft() {
		return left;
	}


	public void setLeft(int left) {
		this.left = left;
	}


	public int getTop() {
		return top;
	}


	public void setTop(int top) {
		this.top = top;
	}


	public BMM getProcesso() {
		return processo;
	}


	public void setProcesso(BMM processo) {
		this.processo = processo;
	}


	public List<ActivityFlow> getListaActivity() {
		return listaActivity;
	}


	public void setListaActivity(List<ActivityFlow> listaActivity) {
		this.listaActivity = listaActivity;
	}


	public List<ConnectorProcess> getListaConnectorProcessDe() {
		return listaConnectorProcessDe;
	}


	public void setListaConnectorProcessDe(
			List<ConnectorProcess> listaConnectorProcessDe) {
		this.listaConnectorProcessDe = listaConnectorProcessDe;
	}


	public List<ConnectorProcess> getListaConnectorProcessPara() {
		return listaConnectorProcessPara;
	}


	public void setListaConnectorProcessPara(
			List<ConnectorProcess> listaConnectorProcessPara) {
		this.listaConnectorProcessPara = listaConnectorProcessPara;
	}


	public List<ConnectorActivity> getConnectorActivity() {
		return connectorActivity;
	}


	public void setConnectorActivity(List<ConnectorActivity> connectorActivity) {
		this.connectorActivity = connectorActivity;
	}
    
    
    
	
}
